/**
 * 作者:hanbo
 * 日期:2018/11/1915:40
 * 描述:图层管理器
 */
export class LayerManager {
    constructor(mapView) {
        this._mapView = mapView;
        this._layers = [];
    }

    /**
     * 视图变化结束，重新绘图各图层
     */
    onViewChanged(render,extend,level) {
        render.clear();//清理之前绘制内容
        console.log(level);
        //循环绘制每个图层
        let amount=this._layers.length;
        for (let i = 0; i < amount; i++) {
            this._layers[i].draw(render,extend,level,amount,i);
        }
    }

    /**
     * 添加图层
     * @param layer [Layer]图层
     */
    addLayer(layer) {
        this._layers.push(layer);
    }

    removeLayer(layer) {
        for (let i = 0; i < this._layers.length; i++) {
            if (this._layers[i].uuid == layer.uuid) {
                this._layers.splice(i, 1);//图层管理中删除图层
                this._mapView._mapRender.removeBrushByLayer(layer.uuid);//删除图层已绘制信息
                break;
            }
        }
    }
}